﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using MySql.Data.MySqlClient;
using System.Threading;

namespace 不动产证管理系统wpf
{
    /// <summary>
    /// Page1.xaml 的交互逻辑
    /// </summary>
    public partial class Page1 : Page
    {
        public Mysqlhelp main1;
        public Page1(Mysqlhelp main1)
        {
            this.main1 = main1;
            InitializeComponent();
        }
        
        private async void Button_Click1(object sender, RoutedEventArgs e)
        {
            Debug.Print("点击了查询");
            await Task.Run(() =>
            {

                try
                {
                    if (Mysqlhelp.mySqlConnection == null)
                    {

                        Debug.Print($"连接地址是：{Mysqlhelp.mConnectdbPath}");
                        Mysqlhelp.mySqlConnection = new MySqlConnection(Mysqlhelp.mConnectdbPath);
                        Mysqlhelp.mySqlConnection.Open();
                        Debug.Print("静态全局变量连接数据库成功2");

                    }
                }
                catch (Exception)
                {
                    Debug.Print("连接数据库失败2");
                    return;
                }

            });
            MySqlCommand mySqlCommand = new MySqlCommand("select count(*) from abc ", Mysqlhelp.mySqlConnection);
            Debug.Print(mySqlCommand.ExecuteScalar().ToString());


            //Debug.Print("点击了查询");

            //MySqlCommand mySqlCommand = new MySqlCommand("select count(*) from test ", main1.mySqlConnection);

            //Debug.Print($"窗口传递参数方法,数据库一共:{mySqlCommand.ExecuteScalar().ToString()}条");



        }
    }
}
